#include <iostream>
#include <cstdio>
#include <cmath>


using namespace std;

struct car{
    int d,v,a;
    bool chao=false;
    double startchao;
    double endchao;
    double leave;
    int startex;
    int endex;
};


struct cesu{
    int dis;
    bool use=false;
    int time=0;
};
car cars[100005];
cesu p[100005];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int ttt=0;ttt<T;ttt++){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        int sum=0;
        int close=m;
        for(int i=0;i<n;i++){
            scanf("%d%d%d",&cars[i].d,&cars[i].v,&cars[i].a);
            if(cars[i].a<0){
                double t=(0-cars[i].v)/(double)cars[i].a;
                double lea=cars[i].d+cars[i].v*t+0.5*cars[i].a*pow(t,2);
                if(lea<L){
                    cars[i].leave=lea;
                }
                else{
                    cars[i].leave=L;
                }
            }
            else{
                cars[i].leave=L;
            }
        }
        for(int i=0;i<m;i++){
            scanf("%d",&p[i].dis);
        }
        for(int i=0;i<n;i++){
            if(cars[i].a>0){
                double t=(V-cars[i].v)/(double)cars[i].a;
                cars[i].startchao=cars[i].d+cars[i].v*t+0.5*cars[i].a*pow(t,2);
                if(cars[i].startchao<=cars[i].leave){
                    cars[i].endchao=m-1;
                    for(int k=0;k<m;k++){
                        if(p[k].dis>cars[i].startchao && p[k].dis>=cars[i].d){
                            cars[i].chao=true;
                            p[k].use=true;
                            cars[i].startex=k;
                            break;
                        }
                    }
                }
            }
            else if(cars[i].a==0){
                if(cars[i].v>V){
                    cars[i].startchao=cars[i].d;
                    for(int k=0;k<m;k++){
                        if(p[k].dis>=cars[i].d){
                            cars[i].chao=true;
                            p[k].use=true;
                            cars[i].startex=k;
                            break;
                        }
                    }
                    cars[i].endex=m-1;
                }

            }
            else{

                double t=(V-cars[i].v)/(double)cars[i].a;
                cars[i].endchao=cars[i].d+cars[i].v*t+0.5*cars[i].a*pow(t,2);
                if(cars[i].endchao>cars[i].d){

                    if(cars[i].endchao>L){
                        cars[i].endex=m-1;

                    }
                    for(int k=0;k<m;k++){
                        if(p[k].dis<cars[i].endchao && p[k].dis>=cars[i].d && p[k].dis<=cars[i].leave){
                            cars[i].chao=true;
                            p[k].use=true;
                            cars[i].startex=k;
                            break;

                        }
                        if(p[k].dis>=cars[i].endchao && p[k].dis>=cars[i].d){
                            cars[i].endex=k;
                            break;
                        }

                    }

                }

            }



        }




        for(int i=0;i<n;i++){
            if(cars[i].chao){
                sum++;
            }
            for(int st=cars[i].startex;st<=cars[i].endex;st++){
                p[st].time++;
            }
        }

        p[m].time=0;

        for(int i=1;i<=m;i++){
            if(p[i].use){
                close--;
            }
        }
        cout<<sum<<" "<<close<<endl;

        for(int i=0;i<m;i++){
            p[i].use=false;
            p[i].time=0;
        }
        for(int i=0;i<n;i++){
            cars[i].chao=false;
            cars[i].endchao=NULL;
            cars[i].startchao=NULL;
            cars[i].leave=NULL;
            cars[i].endex=NULL;
            cars[i].startex=NULL;
        }

    }



    fclose(stdin);
    fclose(stdout);

    return 0;
}
